

load basepara_all;

ncountries = spara(1);
nsectors   = spara(2);
beta       = spara(3);
theta      = spara(4);
sigmaH     = spara(5);
gL         = spara(6);
dbar       = spara(7);
delta3      = spara(8);
L(1)       = spara(9);
L(2)       = spara(10);
alpha(1)  = spara(11);
alpha(2)  = spara(12);
sigmaF    = spara(13);


rho   = beta*(1-delta3);
rbest = delta3/(theta*(1-beta*(1-delta3))+delta3);

ns = nsectors;
n = ncountries;

betas = ones(nsectors,1)/nsectors;


sigma = sigmaH;
%%%%%%%%%% Don't change the above code %%%%%%%%%%%
global theta dbar  L gL alpha rbest rho sigma ns n betas d ilog_rL delta3 beta

% private eqm
r_private = rbest;
n  = ncountries;
ns = nsectors;
ilog_rL = 1; % use exp(rL)/(1+exp(rL))

dij = dbar;
d=dij*ones(n); %dij is (1+iceberg) cost producing in j selling to i
d=d-(dij-1)*eye(n);


%% solve for the steady state of gov assuming dG2/dT=0!!!
% This is not the true steady state, it's only for us to get initial guess
% --- steady state ---


options = optimoptions('fsolve', 'TolFun', 1e-12);
options.Display = 'off';

xguess(1:2) = 1.1;
xguess(3) = 0.2;

[xval,fval_sol,eflag_ss] = fsolve(@(xval) solve_1s_2c_gov_ss_nogL(xval),xguess,options); %iter


[Tss,xss,Pss,pi_ss, fval_ss] = eval_1s_2c_gov_ss_nogL(xval);

xval_ss= xval;
wss = xval(1:n);
extax_ss = xval(3);
taf_ss = 0;
rss = rbest;
lrss = log(rbest);

riskfree_ss = 1/beta;
rmul_ss = (1+theta*pi_ss(2,2))/(1+extax_ss)-theta*pi_ss(2,2);


